package com.example.discover.navigation

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.example.discover.view.DiscoverListScreen
import com.example.discover.view.LayoutConstraints
import com.example.discover.viewmodel.DiscoverListViewModel


@OptIn(ExperimentalUnitApi::class)
@ExperimentalFoundationApi
fun NavGraphBuilder.discoverNestedNavigationGraph(navHostController: NavHostController, featureKey:String) {

    NavigationController.instance.navController = navHostController

    navigation(startDestination = Screen.DiscoverList.route, route = featureKey) {

        composable(Screen.DiscoverList.route) {

            val  viewModel: DiscoverListViewModel = hiltViewModel()
            val uiConstraints = LayoutConstraints.init(LocalConfiguration.current)

            DiscoverListScreen(viewModel.uiState, uiConstraints)

//            val bookViewModel: BooksViewModel = hiltViewModel()
//            val uiState by bookViewModel.uiState.collectAsState()
//            FullScreen {
//                BooksScreen(uiState, bookViewModel.commands)
//            }
        }
    }
}